#!/bin/csh
#Plot 2-D velocity and standard error by GMT

  set bds=-122/-106/22/36
#--------------------------velocity--------------------------

  makecpt -Crainbow -I -T4.00/4.4/.02 >! anomaly.cpt

foreach file (`ls shearvel.*km.dat `)
set fn1=`echo $file | sed 's/.dat//' `
set depth=`echo $file | awk -F. '{print $2}' `

#***************************************

xyz2grd -R$bds -I.2 $fn1.dat -G$fn1.grd2
psbasemap -R$bds -JM5.5i -Ba2f2  -Y1.15 -K -P >! $fn1.ps
psclip clippoly2 -R$bds -JM5.5i -K -O -P >> $fn1.ps
grdimage $fn1.grd2 -R$bds -Canomaly.cpt -JM5.5i -Ba2f2 -K -O -P >> $fn1.ps
#grdcontour $fn1.grd2 -C.5 -JM5.5i -Ba2f2 -K -O -P >> $fn1.ps
psclip -C -O -K -P >> $fn1.ps
pscoast -R$bds -Dl -A250 -JM5.5i  -W1p -Na -K -O -P >> $fn1.ps
psxy stations.txt -R$bds -JM5.5i -Sc0.2c -G255/0/0 -N -: -O -K -P >> $fn1.ps
#psxy $faniso -R$bds -JM5.5i -G0 -SV0.05/0/0 -N -: -O -K -P >> $fn1.ps
psscale -D2.75i/7i/5.65i/.25ih -B0.1:"$depth km shear velocity (km/s) ":/:: -Canomaly.cpt -O -P >> $fn1.ps
end


#--------------------------standard error--------------------

makecpt -Crainbow -T0/6/.5 >! error.cpt

foreach file (`ls  stdde_percentage*km.dat `)
set fn2=`echo $file | sed 's/.dat//' `
set depth=`echo $file | awk -F. '{print $2}' `

#*******************************************

xyz2grd -R$bds -I.2 $fn2.dat -G$fn2.grd2
psbasemap -R$bds -JM5.5i -Ba2f2  -Y1.15 -K -P >! $fn2.ps
psclip clippoly2 -R$bds -JM5.5i -K -O -P >> $fn2.ps
grdimage $fn2.grd2 -R$bds -Cerror.cpt -JM5.5i -Ba2f2 -K -O -P >> $fn2.ps
#grdcontour $fn2.grd2 -C.05 -JM5.5i -Ba2f2 -K -O -P >> $fn2.ps
psclip -C -O -K -P >> $fn2.ps
pscoast -R$bds -Dl -A250 -JM5.5i  -W1p -Na -K -O -P >> $fn2.ps
psxy stations.txt -R$bds -JM5.5i -Sc0.2c -G255/0/0 -N -: -O -K -P >> $fn2.ps
psscale -D2.5i/7i/5.5i/.25ih -B.5:"$depth km  2 x standard error (%)":/:: -Cerror.cpt -O -P >> $fn2.ps
end


rm *~ *grd2 *.cpt
